/*-----------------------------
----$Source: Volumes://MATEOR/vais/modules/braindo/memorize.c$
----$Date: June 30, 2012$
-------------------------------
VAIS Copyright Matthew Caswell, 2012
-----------------------------*/
#include<stdio.h>
#include<stdlib.h>
#include<braindo.h>
#include<lstring.h>
#include<vais.h>
#include<string.h>
#include<lds_ts.h>
#include<time.h>

void DS_TS (char* str, char* DS_Record);

void VAIS_Memorize (char* str, char* tipo, char* DS_Record){
  if(strcmp(tipo, "DS_TS") == 0){
    DS_TS (str, DS_Record);
  }else{
    debug (tipo, "Unknown memory type?", "braindo/memorize.c");
    printf ("\e[1;36m%s is not a valid neuro path in my memory!  This is a bug.\e[0m\n", tipo);
  }
}

void DS_TS (char* str, char* DS_Record){
  char VAIS_TS_B[23];
  time_t t = time (0);
  struct tm* now = localtime (&t);

  int n;
  n = sprintf(VAIS_TS_B, "PP%iD%s", (((((((((now->tm_year - 100) * 100) + (now->tm_mon+1)) * 100) + (now->tm_mday)) * 100) + (now->tm_hour)) * 100) + (now->tm_min)), str);
  
  FILE* DS_File;
  DS_File = fopen (DS_Record, "w");
  fwrite (VAIS_TS_B, 1, sizeof (VAIS_TS_B), DS_File);
  debug ("VAIS_TS_B", "DS_TS", "braindo/memorize.c");
  fclose (DS_File);
}